package com.devbobcorn.nekorization.client.rendering;

import com.devbobcorn.nekorization.Nekorization;
import com.devbobcorn.nekorization.client.model.NekoModel;
import com.devbobcorn.nekorization.entities.NekoEntity;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class NekoOuterLayer extends NekoAbstractLayer {
    private static final ResourceLocation BOWTIE = new ResourceLocation(Nekorization.MODID, "textures/entity/neko/bowtie.png");
    private static final ResourceLocation SHIRT  = new ResourceLocation(Nekorization.MODID, "textures/entity/neko/shirt_outer.png");
	private static final ResourceLocation SKIRT  = new ResourceLocation(Nekorization.MODID, "textures/entity/neko/skirt_outer.png");
    private static final ResourceLocation SHOES  = new ResourceLocation(Nekorization.MODID, "textures/entity/neko/shoes_outer.png");

	public NekoOuterLayer(RenderLayerParent<NekoEntity, NekoModel<NekoEntity>> parent, NekoModel<NekoEntity> model) {
		super(parent, model);
	}

	public void render(PoseStack stack, MultiBufferSource buffers, int l, NekoEntity entity, float a, float b, float c, float d, float e, float f) {
		// Setup model, then render hair...
        setHairVisible();
		coloredCutoutModelCopyLayerRender(this.getParentModel(), this.nekoModel, entity.getOuterHair(), stack, buffers, l, entity, a, b, d, e, f, c, 1.0F, 1.0F, 1.0F);
        if (entity.isInvisible()) return; // Invisibility check...
        // Render bowtie...
        setShirtVisible();
        float[] bowtieColor = entity.getCollarColor().getTextureDiffuseColors();
        renderColoredCutoutModel(this.nekoModel, BOWTIE, stack, buffers, l, entity, bowtieColor[0], bowtieColor[1], bowtieColor[2]);
		// Render shirt...
        renderColoredCutoutModel(this.nekoModel, SHIRT, stack, buffers, l, entity, 1.0F, 1.0F, 1.0F);
        // Render skirt...
        setSkirtVisible();
        renderColoredCutoutModel(this.nekoModel, SKIRT, stack, buffers, l, entity, 1.0F, 1.0F, 1.0F);
        // Render shoes...
        nekoModel.body.visible = false;
        renderColoredCutoutModel(this.nekoModel, SHOES, stack, buffers, l, entity, 1.0F, 1.0F, 1.0F);
	}
}